﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace videoTest
{
    class movements
    {



        public Int32 convert(Int32 conv)
        {
            Int32 sendData = 0;
            // string sendDataY = "Y0";

            Int32 temp;
            //double tempY;

            if (conv > 115 && conv < 215)
            {
                temp = conv - 100;

                if (temp > 100)
                {
                    temp = 100;
                }

                sendData = temp;

             

                return sendData;

                //convDataY.Text = sendDataX;
                //fez.sendData(sendDataX);
            }



            if (conv <= 115 && conv >= 95)
            {
                temp = 0;
                sendData = temp;
                return sendData;
                //convDataY.Text = sendDataX;
                //fez.sendData(sendDataX);
            }


            if (conv < 100 && conv > 0)
            {
                temp = (conv - 100) * 2;

                if (temp < -100)
                {
                    temp = -100;
                }

                sendData = temp;
                return sendData;
                //convDataY.Text = sendDataX;
                //fez.sendData(sendDataX);

            }
            if (conv > 215)
            {
                sendData = 100;
                return sendData;
            }

            else
            {
                sendData = 0;
                return sendData;
            }

        }


        public string convertSend_X(double convX)
        {
            string sendDataX = "X0";
            // string sendDataY = "Y0";

            double tempX;
            //double tempY;

            if (convX > 115 && convX < 215)
            {
                tempX = convX - 100;

                if (tempX > 100)
                {
                    tempX = 100;
                }

                App.xValue = Convert.ToInt16(tempX);

                sendDataX = "X" + tempX;

                return sendDataX;

                //convDataY.Text = sendDataX;
                //fez.sendData(sendDataX);
            }

          

            if (convX <= 115 && convX >= 95)
            {
                tempX = 0;

                App.xValue = Convert.ToInt16(tempX);

                sendDataX = "X" + tempX;
                return sendDataX;
                //convDataY.Text = sendDataX;
                //fez.sendData(sendDataX);
            }


            if (convX < 100 && convX > 0)
            {
                tempX = (convX - 100) * 2;

                if (tempX < -100)
                {
                    tempX = -100;
                }

                App.xValue = Convert.ToInt16(tempX);

                sendDataX = "X" + tempX;
                return sendDataX;
                //convDataY.Text = sendDataX;
                //fez.sendData(sendDataX);

            }
            if (convX > 215)
            {
                App.xValue = 100;
                sendDataX = "X100";
                return sendDataX;
            }

            else
            {
                App.xValue = 0;
                sendDataX = "X0";
                return sendDataX;
            }

        }

        public string convertSend_Y(double convY)
        {
            string sendDataY = "Y0";

            double tempY;

            if (convY > 115 && convY < 215)
            {
                tempY = convY - 100;
                if (tempY > 100)
                {
                    tempY = 100;
                }


                App.yValue = Convert.ToInt16(tempY);

                sendDataY = "Y" + tempY;
                return sendDataY;
                //convDataX.Text = sendData;
                //fez.sendData(sendData);
            }
            if (convY <= 115 && convY >= 95)
            {
                tempY = 0;
                App.yValue = Convert.ToInt16(tempY);
                sendDataY = "Y" + tempY;
                return sendDataY;
                //convDataX.Text = sendData;
                //fez.sendData(sendData);
            }
            if (convY < 100 && convY > 0)
            {
                tempY = (convY - 100) * 2;


                if (tempY < -100)
                {
                    tempY = -100;
                }

                App.yValue = Convert.ToInt16(tempY);
                sendDataY = "Y" + tempY;
                return sendDataY;
                //convDataX.Text = sendData;
                //fez.sendData(sendData);


            }

            if (convY > 215)
            {
                App.yValue = 100;
                sendDataY = "Y100";
                return sendDataY;
            }

            else
            {
                App.yValue = 0;
                sendDataY = "Y0";
                return sendDataY;
            }


        }
    }
}
